package ar.edu.unlp.info.dssd.dao;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Property;

import ar.edu.unlp.info.dssd.modelo.Conductor;

public class ConductorDao extends AbstractDao {
	
	public Conductor guardarConductor(Conductor conductor){
		return (Conductor)super.save(conductor);
	}
	
	public Conductor actualizarConductor(Conductor conductor){
		return (Conductor)super.update(conductor);
	}

	public Conductor login(String username, String password) {
		Conductor result = null;
		DetachedCriteria criteria = DetachedCriteria.forClass(Conductor.class).add(Property.forName("dni").eq(username));

		List<Conductor> results = this.getHibernateTemplate().findByCriteria(criteria);
		if (results.size() > 0){
			result = results.get(0);
		}
		return result;
	}
	
	
}
